import 'package:flutter/material.dart';

class Widget_BottomNavigationBar_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_BottomNavigationBar_State();
  }
}

/**
    BottomNavigationBar({
    Key key,
    @required this.items,//子选项
    this.onTap,
    this.currentIndex = 0,//选中第几个
    BottomNavigationBarType type,
    this.fixedColor,//文字颜色
    this.iconSize = 24.0,//icon图片大小
    })
 */

/**
    const BottomNavigationBarItem({
    @required this.icon,//未选中图标
    this.title,//文字
    Widget activeIcon,//选中图标
    this.backgroundColor,// 测试发现type设置为shifting时，backgroundColor才有效
    })
 */
class Widget_BottomNavigationBar_State
    extends State<Widget_BottomNavigationBar_Page> {
  int choiceIndex = 0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("BottomNavigationBar"),),
        bottomNavigationBar: BottomNavigationBar(
          items: [
            BottomNavigationBarItem(
              icon: Icon(Icons.home),
              title: Text(
                "首页", /*style: TextStyle(color: Color(0xff333333)),*/),
              activeIcon: Icon(
                Icons.home,
                color: Color(0xffDE331F),
//                size: 30.0,
              ),
              backgroundColor: Color(0xffff0000),
            ),
            BottomNavigationBarItem(
              icon: Icon(Icons.devices_other),
              title: Text(
                "其他", /*style: TextStyle(color: Color(0xff333333)),*/),
              activeIcon: Icon(
                Icons.devices_other,
                color: Color(0xffDE331F),
//                size: 30.0,
              ),
              backgroundColor: Color(0xffff0000),
            ),
          ],
          currentIndex: choiceIndex,
          fixedColor: Color(0xffDE331F),
//          iconSize: 30.0,
//          type: BottomNavigationBarType.fixed,
          onTap: (index) =>
              setState(
                      () {
                        choiceIndex  = index;
                        print(choiceIndex.toString());
                  }
              ),
        ),
      ),
    );
  }
}

